<template>
  <div>
    <div class="main clear-fix">
      <div
        class="main-list"
        v-for="item in recommendList"
        :key="item.id"
        @click="handelClick(item.id)"
      >
        <img :src="item.masterImg" alt="" />
        <p>{{ item.title }}</p>

        <span>{{ item.label[0] }}</span>
        <span>{{ item.label[1] }}</span>

        <div class="header-imgs">
          <img :src="item.headImg" alt="" />
          <em class="header-id">{{ item.username }}</em>
        </div>
        <div class="images">
          <div class="iconic">
            <img src="../../../assets/img/kanguo.png" alt="" />
            <i>{{ item.browse }}</i>
          </div>
          <div class="iconics">
            <img src="../../../assets/img/zan.png" alt="" />
            <i>{{ item.likes }}</i>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { onMounted, ref, watch } from "vue";
import { useRouter } from "vue-router";
export default {
  props: ["msg"],
  setup(props) {
    const router = useRouter();
    const recommendList = ref(null);

    watch(props, () => {
      recommendList.value = recommendList.value.sort(() => {
        return Math.random() - 0.5;
      });
    });

    onMounted(() => {
      fetch(`http://2107.wqdp.com.cn/index/recommend?count=8`)
        .then((response) => {
          return response.json();
        })
        .then((res) => {
          recommendList.value = res.result.sort(() => {
            return Math.random() - 0.5;
          });
        });
    });
    const handelClick = (id) => {
      router.push("/circleinfo/" + id);
    };
    return { recommendList, handelClick };
  },
};
</script>

<style lang="less" scoped>
.clear-fix:after {
  content: "";
  height: 0;
  clear: both;
  overflow: hidden;
  display: block;
  visibility: hidden;
}
.main {
  margin-top: 50px;
  padding: 10px 0 0 10px;
  // overflow: hidden;
  // background: url(../../../assets/img/background1.png) repeat;
  background-origin: border-box;
}
.main-list {
  float: left;
  width: 174px;
  height: 283px;
  background: #ffffff;
  border-radius: 9px;
  margin-right: 5px;
  margin-bottom: 10px;

  img {
    width: 174px;
    height: 181px;
    border-radius: 9px 9px 0px 0px;
  }

  p {
    // width: 79px;
    height: 12px;
    font-size: 13px;
    font-family: PingFang;
    font-weight: bold;
    color: #333333;
    line-height: 18px;
    margin-left: 10px;
  }

  span {
    display: inline-block;
    // width: 36px;
    height: 15px;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 10px;
    font-family: PingFang;
    font-weight: 500;
    color: #999999;
    line-height: 18px;
    margin-left: 10px;
  }
}
.header-imgs {
  overflow: hidden;
}

.header-imgs img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  float: left;
  margin-left: 10px;
}

.header-id {
  // display: inline-block;
  font-size: 8px;
  font-family: PingFang;
  font-weight: 500;
  color: #666666;
  line-height: 18px;
  margin-left: 6px;
  float: left;
}
.iconic {
  float: left;
  margin-left: 20px;
}
.iconics {
  float: right;
  margin-right: 20px;
}
.iconic img,
.iconics img {
  width: 14px;
  height: 10px;
  margin-right: 5px;
  border-radius: 0;
}
.iconic i,
.iconics i {
  width: 23px;
  height: 8px;
  font-size: 10px;
  font-family: Helvetica;
  font-weight: 400;
  color: #999999;
  line-height: 18px;
}
</style>
